﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="JYH.Web.MES.Index" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>捷易晧智能制造平台</title>
    <link rel="stylesheet" type="text/css" href="themes/uimaker/easyui.css" />
    <link rel="stylesheet" type="text/css" href="css/uimaker.css" />
    <link rel="stylesheet" type="text/css" href="font/iconfont.css" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/JYH.Core.js"></script>
    <script>
        function addTab(title, url) {
            if ($('#tt').tabs('exists', title)) {
                $('#tt').tabs('select', title);
            } else {
                var content = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
                $('#tt').tabs('add', {
                    title: title,
                    content: content,
                    closable: true
                });
            }
        }
        //tree组件整体点击效果
        $(function () {

            $("div.tree-node").on("click", function (e) {
                if ($(e.target).hasClass("tree-node")) {
                    $(this).children("span.tree-title").children('a').trigger("click");
                }
            });
           

        });
    </script>

    <script type="text/javascript">


        let res = {};
        //删除Tabs
        function closeTab(menu, type) {
            var allTabs = $("#tt").tabs('tabs');
            var allTabtitle = [];
            $.each(allTabs, function (i, n) {
                var opt = $(n).panel('options');
                if (opt.closable)
                    allTabtitle.push(opt.title);
            });
            var curTabTitle = $(menu).data("tabTitle");
            var curTabIndex = $("#tt").tabs("getTabIndex", $("#tt").tabs("getTab", curTabTitle));
            switch (type) {
                case 1:
                    $("#tt").tabs("close", curTabIndex);
                    return false;
                    break;
                case 2:
                    for (var i = 0; i < allTabtitle.length; i++) {
                        $('#tt').tabs('close', allTabtitle[i]);
                    }
                    break;
                case 3:
                    for (var i = 0; i < allTabtitle.length; i++) {
                        if (curTabTitle != allTabtitle[i])
                            $('#tt').tabs('close', allTabtitle[i]);
                    }
                    $('#tt').tabs('select', curTabTitle);
                    break;
                case 4:
                    for (var i = curTabIndex; i < allTabtitle.length; i++) {
                        $('#tt').tabs('close', allTabtitle[i]);
                    }
                    $('#tt').tabs('select', curTabTitle);
                    break;
                case 5:
                    for (var i = 0; i < curTabIndex - 1; i++) {
                        $('#tt').tabs('close', allTabtitle[i]);
                    }
                    $('#tt').tabs('select', curTabTitle);
                    break;
                case 6: //刷新
                    var panel = $("#tt").tabs("getTab", curTabTitle).panel("refresh");
                    break;
            }
        }
        function GetMenu(MenuGroup) {
            var UserNO = GetCookieUser();
            var abc = {
                UserNO: UserNO,
                MenuGroup: MenuGroup
            };
            var url = "api/Sys/GetUserMenu";
            // var element = document.getElementById("Literal1");

            $.ajax({
                url: url, // 替换为你的API或服务器端点
                type: 'POST', // 或者 'POST'，取决于你的请求类型
                data: abc,
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                success: function (data) {
                    // 假设你需要在请求成功后显示元素
                    if (data.Code == "200") {

                        var element = document.getElementById("divMenu");
                        if (element) {

                            $("#divMenu").html(" <div  id=\"divMenu\"  data-options=\"region: 'west', split: true, border: false, title: '管理菜单', iconCls: 'icon-yingyong-copy'\" class=\"left\">" + data.Items[0].HtmlMenu + "   </div>");
                        }

                        $(".easyui-accordion").accordion();
                        $('.easyui-tree').tree();
                    }

                },
                error: function (xhr, status, error) {
                    // 错误处理
                }
            });



        }
        $(document).ready(function () {
            //监听右键事件，创建右键菜单
            $('#tt').tabs({
                onContextMenu: function (e, title, index) {
                    e.preventDefault();
                    if (index > 0) {
                        $('#mm').menu('show', {
                            left: e.pageX,
                            top: e.pageY
                        }).data("tabTitle", title);
                    }
                }
            });
            //右键菜单click
            $("#mm").menu({
                onClick: function (item) {
                    closeTab(this, item.name);
                }

            });


            makeRequestsInSequence("Module");
            TranslationPage();


        });
        async function TranslationPage()
        {

            try {
                var lang = {
                    PageName: 'Index',
                    LanguageNO: navigator.language
                };

                var url = "/api/SYS/GetPageLanguage";

                // var element = document.getElementById("Literal1");

                let c = await $.ajax({
                    url: url, // 替换为你的API或服务器端点
                    type: 'POST', // 或者 'POST'，取决于你的请求类型
                    data: lang,
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    success: function (data) {
                        // 假设你需要在请求成功后显示元素
                        if (data.Code == 200) {
                            res = data.Items[0];
                            if (res != null) {
                               document.getElementById("BaseData").textContent = res.BaseData;
                                document.title = res.PageTitile;
                                document.getElementById("Warehouse").textContent = res.Warehousing;
                                document.getElementById("Manufacturing").textContent = res.Manufacturing;
                                document.getElementById("Quanlity").textContent = res.Quality;
                                document.getElementById("Process").textContent = res.Process;
                                document.getElementById("Device").textContent = res.Device;
                                document.getElementById("Report").textContent = res.Report;
                            }
                        }
                        if (data.Code == 500) {
                            Notice(data.Message);

                        }

                    },
                    error: function (xhr, status, error) {
                        // 错误处理
                    }
                });



            } catch (error) { }
             //  console.error('Request error:', error);
     
        };
        async function makeRequestsInSequence(MenuGroup) {
            try {
                var UserNO = GetCookieUser();
                var abc = {
                    UserNO: UserNO,
                    MenuGroup: MenuGroup
                };
                var url = "api/SYS/GetWebMenu";
                // var element = document.getElementById("Literal1");

                let b = await $.ajax({
                    url: url, // 替换为你的API或服务器端点
                    type: 'POST', // 或者 'POST'，取决于你的请求类型
                    data: abc,
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    success: function (data) {
                        // 假设你需要在请求成功后显示元素
                        if (data.Code == "200") {

                            var element = document.getElementById("divMenu");
                            if (element) {

                                $("#divMenu").html(" <div  id=\"divMenu\"  data-options=\"region: 'west', split: true, border: false, title: '" + res.PageTitile +"', iconCls: 'icon-yingyong-copy'\" class=\"left\">" + data.Items[0].HtmlMenu + "   </div>");
                            }

                            $(".easyui-accordion").accordion();
                            $('.easyui-tree').tree();
                        }

                    },
                    error: function (xhr, status, error) {
                        // 错误处理
                    }
                });



            } catch (error) {
               // console.error('Request error:', error);
            }
        }
    </script>
</head>
<body class="easyui-layout" style="background: #fff;" runat="server">
    <form id="form1" runat="server">

    <div data-options="region:'north',border:false" class="header">
        <div class="logo">
            <img src="images/JYHLogo.png" style="width: 47px; height: 39px"/>
        </div>

        <ul class="nav" id="nav">
         <li><a id="BaseData" href="#" onclick="makeRequestsInSequence('Module')"><i class="iconfont">&#xe617;</i>基础资料</a></li>
         <li><a id="Warehouse" href="#" onclick="makeRequestsInSequence('Warehouse')"><i class="iconfont">&#xe616;</i>仓库管理</a></li>
         <li><a id="Manufacturing" href="#" onclick="makeRequestsInSequence('Manufacturing')"><i class="iconfont">&#xe78e;</i>生产管理</a></li>
         <li><a id="Quanlity" href="#" onclick="makeRequestsInSequence('Quanlity')"><i class="iconfont">&#xe605;</i>品质管理</a></li>
         <li><a id="Process" href="#" onclick="makeRequestsInSequence('Process')"><i class="iconfont">&#xe61b;</i>工艺管理</a></li>
         <li><a id="Device"href="#" onclick="makeRequestsInSequence('Device')"><i class="iconfont">&#xe60e;</i>设备管理</a></li>
         <li><a id="Report" href="#" onclick="makeRequestsInSequence('Report')"><i class="iconfont">&#xe600;</i>报表看板</a></li>
     
        </ul>
        <div class="topright">
            <ul class="toptool">
               <%-- <li><a href="#"><i class="iconfont">&#xe6ba;</i></a><em>3</em></li>
                <li><a href="#"><i class="iconfont">&#xe60c;</i></a><em class="gcolor">5</em></li>
                <li><a href="#"><i class="iconfont">&#xe61a;</i></a></li>--%>
                <li><span class="userface"><i class="iconfont">&#xe60d;</i></span><a href="#"  id="aUserName"  class="uldown"><font> <i class="iconfont userdown">&#xe618;</i></font></a>
                </li>
            </ul>
        </div>

    </div>

    <ul class="userlist">
        <li><a href="#" onclick="$('#pwd').dialog('open')"><i class="userxl iconfont">&#xe616;</i>修改密码</a></li>
        <li><a href="login.aspx"><i class="userxl iconfont">&#xe601;</i>退出</a></li>
    </ul>
    
    <script type="application/javascript">
        $(function () {
            $('.uldown').click(function (event) {
                //取消事件冒泡  
                event.stopPropagation();
                //按钮的toggle,如果div是可见的,点击按钮切换为隐藏的;如果是隐藏的,切换为可见的。  
                $('.userlist').toggle('fast');

                return false;
            });

            //点击空白处隐藏弹出层，下面为滑动消失效果和淡出消失效果。
            $(document).click(function (event) {
                var _con = $('.userlist');   // 设置目标区域
                if (!_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
                    //$('.userlist').slideUp('slow');   //滑动消失
                    $('.userlist').hide(200);          //淡出消失
                }
            });
        })

        //重置
        function clearForm() {
            // 清空用户姓名输入框
            $('#txtUserName').textbox('setValue', '');
            // 清空旧密码输入框
            $('#pwd1').textbox('setValue', '');
            // 清空新密码输入框
            $('#pwd2').textbox('setValue', '');
            // 清空确认密码输入框
            $('#pwd3').textbox('setValue', '');
        }

        //确认修改
        function submitForm() {
            // 获取输入框的值
            var userName = $('#txtUserName').textbox('getValue');
            var oldPassword = $('#pwd1').textbox('getValue');
            var newPassword = $('#pwd2').textbox('getValue');
            var confirmPassword = $('#pwd3').textbox('getValue');

            // 验证用户姓名是否为空
            if (!userName) {
                Alert('提示', '用户姓名不能为空', 'warning');
                return;
            }

            // 验证旧密码是否为空
            if (!oldPassword) {
                Alert('提示', '旧密码不能为空', 'warning');
                return;
            }

            // 验证新密码是否为空
            if (!newPassword) {
                Alert('提示', '新密码不能为空', 'warning');
                return;
            }

            // 验证确认密码是否为空
            if (!confirmPassword) {
                Alert('提示', '确认密码不能为空', 'warning');
                return;
            }
            // 验证新密码和确认密码是否相同
            if (newPassword !== confirmPassword) {
                Alert('提示', '新密码和确认密码不一致', 'warning');
                return;
            }
            // 如果所有验证通过，可以继续提交表单或执行其他操作
            // 例如，发送数据到服务器
            DataService.PostJson('/api/Sys/UpdateLogin', {
                UserName: userName,
                Pwd: oldPassword,
                newPassword: newPassword
            }, function (err, msg) {
                if (err) {
                    Alert('成功', '密码修改成功', 'info');
                    // 可以在这里添加其他成功后的操作，比如关闭对话框
                    window.location.href = 'Login.aspx';
                } else {
                    Alert(msg);
                }
            })
        }
    </script>


    <div  id="divMenu"  data-options="region:'west',split:true,border:false,title:'管理菜单',iconCls:'icon-yingyong-copy'" class="left">
        
            <%--通鑫益具体引用页面--%>
        
    </div>
          
            <script>         
</script>

    <div data-options="region:'south',border:false" class="footer">
        <span class="fleft"><i class="iconfont">&#xe622;</i>捷易晧智能制造平台</span>
        <span class="fright">版权所有@ 2024 江苏捷易晧智能设备科技有限公司<i class="iconfont">&#xe620;</i></span>
    </div>


    <div data-options="region:'center',border:false" class="center">

        <div id="tt" class="easyui-tabs" data-options="fit:true,border:false">
            <div title="首页">
                <iframe src="FirstPage.aspx" id="iframe" name="right" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>
            </div>

        </div>

    </div>

    <div id="pwd" class="easyui-dialog" title="用户信息" data-options="closed:true" style="width: 480px; height: 330px; padding: 10px;">
        <div class="easyui-panel" style="padding: 15px; width: 100%;">
                <ul style="width: 350px;">
                    <li style="margin-bottom: 15px;"> <input class="easyui-textbox" type="text" id="txtUserName" style="width: 100%" data-options="label:'用户姓名:'" aria-readonly="True" /></li>
                    <li style="margin-bottom: 15px;">
                        <input class="easyui-textbox" type="password" id="pwd1" style="width: 100%" data-options="label:'旧密码:'" /></li>
                    <li style="margin-bottom: 15px;">
                        <input class="easyui-textbox" type="password" id="pwd2" style="width: 100%" data-options="label:'新密码:'" /></li>
                    <li style="margin-bottom: 15px;">
                        <input class="easyui-textbox" type="password" id="pwd3" style="width: 100%" data-options="label:'确认密码:'" /></li>
                    <li style="margin-bottom: 15px;"><span class="fspan">&nbsp;</span>
                        <a href="javascript:void(0)" class="easyui-linkbutton c1" onclick="submitForm()" style="width: 80px">确定</a>
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width: 80px">重置</a>
                    </li>
                </ul>
        </div>
    </div>

    <div id="mm" class="easyui-menu" style="width: 120px;">
        <div id="mm-tabclosrefresh" data-options="name:6">刷新</div>
        <div id="mm-tabclose" data-options="name:1">关闭</div>
        <div id="mm-tabcloseall" data-options="name:2">全部关闭</div>
        <div id="mm-tabcloseother" data-options="name:3">其他全部关闭</div>
        <div class="menu-sep"></div>
        <div id="mm-tabcloseright" data-options="name:4">右侧全部关闭</div>
        <div id="mm-tabcloseleft" data-options="name:5">左侧全部关闭</div>
    </div>
    <div style="overflow: auto; display: none" id="mPopWin" data-options="cls:'c1'">
    </div>
    <div style="overflow: auto; display: none" id="cPopWin" data-options="cls:'c5'">
    </div>
    <div style="overflow: auto; display: none" id="tPopWin" data-options="cls:'c3'">
    </div>
        </form>
</body>
</html>